#pragma warning(disable : 4996)
#include<stdio.h>
#include<stdlib.h>
int size;


int main()
{
	FILE *outfile;
	
	int id[100] = {0};
	int sc1[100] = {0};
	int sc2[100] = {0};
	int av[100] = { 0 };
	if ((outfile = fopen("text.dat", "w")) == NULL)
	{
		printf("Failed to open\n");
		exit(100);
	}
	printf("请输入考生数量：\n");
	scanf_s("%d", &size);
	printf("请输入考生信息，用逗号隔开（样例：学号，成绩，成绩）\n");
	fputs("      成绩登记表      \n",outfile);
	for (int i = 0; i < size; i++)
	{
		scanf("%d,%d,%d" , id+i,sc1+i,sc2+i);
		av[i] = (sc1[i] + sc2[i]) / 2;
		fprintf(outfile, "%d,%d,%d,%d\n", id[i], sc1[i], sc2[i],av[i]);
	}
	fclose(outfile);
	return 0;
}